﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WinnerCMS.Common;
using WinnerCMS.Data;
using WinnerCMS.Model;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// AnnounceManage 的摘要说明。
    /// </summary>
    public class AnnounceManage : MarshalByRefObject
    {
        private static readonly AnnounceDal Dal = new AnnounceDal();

        /// <summary>
        /// 添加公告
        /// </summary>
        /// <param name="model"></param>
        [Logging("添加公告：{@p0.Title}"), ExceptionCall]
        public Result Add(Announce model)
        {
            Result res = new Result();

            model.CreateTime = DateTime.Now;
            model.UpdateTime = DateTime.Now;
            Dal.Add(model);


            return res;
        }

        /// <summary>
        /// 修改公告
        /// </summary>
        /// <param name="model"></param>
        [Logging("修改公告ID：{@p0.ID}"), ExceptionCall]
        public Result Edit(Announce model)
        {
            Result res = new Result();

            model.UpdateTime = DateTime.Now;
            Dal.Edit(model);


            return res;
        }

        /// <summary>
        /// 删除公告
        /// </summary>
        /// <param name="ids"></param>
        [Logging("批量删除公告ID：{@p0}"), ExceptionCall]
        public Result Delete(string ids)
        {
            Result res = new Result();
            if (string.IsNullOrEmpty(ids))
            {
                res.Errors = "至少要选择一个。";
                return res;
            }
            Dal.Delete(ids.ToArrInt());
            return res;
        }

        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Announce GetInfo(string id)
        {
            return Dal.GetInfo(int.Parse(id));
        }

        /// <summary>
        /// 审核公告
        /// </summary>
        /// <param name="id"></param>
        [Logging("撤消或审核公告ID：{@p0}"), ExceptionCall]
        public void PassOrUnpass(string id)
        {
            Announce info = Dal.PassOrUnpass(int.Parse(id));
        }

        /// <summary>
        /// 公告列表－－前台使用
        /// </summary>
        /// <param name="top"></param>
        /// <returns></returns>
        public IList<Announce> BindList(int top)
        {
            return Dal.BindList(top);
        }


        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="pass"></param>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<Announce> BindList(bool? pass, PagingParam pp)
        {
            return Dal.BindList(pass, pp);
        }

        /// <summary>
        /// 显示公告
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Announce Show(int id)
        {
            return Dal.Show(id);
        }
    }
}